package Com.javaserver.servlet;




import Com.javaserver.dao.trainserver;
import Com.javaserver.utils.DB;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/tralist")
public class Showtrainserverlet extends HttpServlet {
            trainserver tra =new trainserver();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String page=req.getParameter("page");
        System.out.println("page= " + page);
        if(page==null){
            page="1";
        }
        List<Map<String, Object>> list = DB.executeQuery("select count(*) count from trian");
        System.out.println(list);
        req.getSession().setAttribute("userLen", list.get(0).get("count"));
        req.getSession().setAttribute("tralist", tra.tralist(Integer.parseInt(page)));
        System.out.println(tra.tralist(Integer.parseInt(page)));
        System.out.println(req.getSession().getAttribute("tralist"));
        req.getSession().setAttribute("nav", "培训管理");
        resp.sendRedirect(req.getContextPath() + "/Training.jsp");
    }
}
